package com.hoki.zj.hrm.utils;

import com.alibaba.fastjson.JSON;
import com.hoki.zj.hrm.domain.LoginUser;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;

public class LoginUserContext {

    public static LoginUser getLoginUser() {
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        String loginUserStr = (String)authentication.getPrincipal(); // 获取封装的loginUserStr
        return JSON.parseObject(loginUserStr, LoginUser.class);
    }
}
